package com.kmproject.haifu.mvp.ui.holder;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.resbean.SecondHandQueryParmar;
import com.kmproject.haifu.mvp.ui.adapter.PopuWindowSelectPxAdapter;

import java.util.Arrays;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PxSecondHandSelectHolder {
    @BindView(R.id.popuwindows_seelct_px_RecyclerView)
    RecyclerView popuwindowsSeelctPxRecyclerView;
    private Context mcontext;
    private PopuWindowSelectPxAdapter popuWindowSelectPxAdapter;

    public PxSecondHandSelectHolder(Context context, View view, PopuWindowSelectPxAdapter.BtncliickCallBack btncliickCallBack) {
        mcontext = context;
//        R.layout.popuwindows_seelct_px
        ButterKnife.bind(this, view);
        popuwindowsSeelctPxRecyclerView.setLayoutManager(new LinearLayoutManager(mcontext));
        popuWindowSelectPxAdapter=new PopuWindowSelectPxAdapter(Arrays.asList(mcontext.getResources().getStringArray(R.array.secondhand_show_list_select_px)), new PopuWindowSelectPxAdapter.BtncliickCallBack() {
            @Override
            public void callBack(int index, Object content) {
                 btncliickCallBack.callBack(index,dataToSearch((String) content));
            }
        });
        popuwindowsSeelctPxRecyclerView.setAdapter(popuWindowSelectPxAdapter);
        popuWindowSelectPxAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);

    }

    /**
     * 转换
     * @param data
     */
 public SecondHandQueryParmar.SortOrdersBean dataToSearch(String data)
 {
     SecondHandQueryParmar.SortOrdersBean sortOrdersBean=null;
  switch (data)
  {
      case "综合排序":
          sortOrdersBean=new SecondHandQueryParmar.SortOrdersBean("desc","viewCount");
          break;
      case "价格（从低到高）":
          sortOrdersBean=new SecondHandQueryParmar.SortOrdersBean("asc","salePrice");
          break;
      case "价格（从高到低）":
          sortOrdersBean=new SecondHandQueryParmar.SortOrdersBean("desc","salePrice");
          break;

      case "最新发布":
          sortOrdersBean=new SecondHandQueryParmar.SortOrdersBean("desc","createTime");
          break;
  }
  return sortOrdersBean;
 }

}
